<template>
  <div class="controller-categories">
    <div class="sci-fi-container">
      <div class="kzq-carousel">
        <Carousel :items-to-show="1" :wrap-around="true" :autoplay="4000">
          <Slide v-for="(image, index) in carouselImages" :key="index">
            <div class="carousel-slide">
              <img :src="image" :alt="`控制器图片 ${index + 1}`" class="carousel-image">
            </div>
          </Slide>

          <template #addons>
            <Navigation />
            <Pagination />
          </template>
        </Carousel>
      </div>

      <div class="sci-fi-header">
        <h1 class="glow-text">控制器分类</h1>
        <div class="sci-fi-decor"></div>
      </div>

      <div class="category-container">
        <div class="category-list">
          <div 
            v-for="(category, index) in categories" 
            :key="index"
            class="category-item"
            :class="{ active: activeCategory === index }"
            @click="setActiveCategory(index)"
          >
            <div class="item-inner">
              <div class="tech-icon">
                <div class="icon-circle"></div>
                <div class="icon-pulse"></div>
              </div>
              <span>{{ category.name }}</span>
            </div>
          </div>
        </div>

        <div class="category-content" v-if="activeCategory !== null">
          <div class="tech-frame">
            <div class="frame-corner top-left"></div>
            <div class="frame-corner top-right"></div>
            <div class="frame-corner bottom-left"></div>
            <div class="frame-corner bottom-right"></div>
            
            <div class="content-header">
              <h2>{{ activeItem.name }}</h2>
              <div class="tech-line"></div>
            </div>
            
            <div class="content-body">
              <div class="tech-specs">
                <div class="tech-image">
                  <img :src="activeItem.image" :alt="activeItem.name" />
                  <div class="image-overlay"></div>
                  <div class="scanning-line"></div>
                </div>
                
                <div class="specs-list">
                  <div class="spec-item" v-for="(spec, i) in activeItem.specs" :key="i">
                    <div class="spec-label">{{ spec.label }}</div>
                    <div class="spec-value">{{ spec.value }}</div>
                  </div>
                </div>
              </div>
              
              <div class="tech-description">
                <h3>产品描述</h3>
                <p>{{ activeItem.description }}</p>
              </div>

              <div class="tech-features">
                <h3>主要特点</h3>
                <ul>
                  <li v-for="(feature, i) in activeItem.features" :key="i">
                    <div class="feature-bullet"></div>
                    {{ feature }}
                  </li>
                </ul>
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script setup>
import { ref, computed } from 'vue';
import { Carousel, Navigation, Pagination, Slide } from 'vue3-carousel';
import 'vue3-carousel/dist/carousel.css';

// 导入轮播图图片
import CF72290 from '@/assets/kzq/CF72290.png';
import CF72350 from '@/assets/kzq/CF72350.jpg';
import NB72290 from '@/assets/kzq/NB72290.png';
import cz from '@/assets/kzq/cz.jpg';
import gn from '@/assets/kzq/gn.jpg';
import zs from '@/assets/kzq/zs.jpg';

// 轮播图图片
const carouselImages = [CF72290, CF72350, NB72290, cz, gn, zs];

// 控制器分类数据
const categories = [
  { 
    name: '极核 72290',
    image: CF72290,
    description: '72290型号控制器是一款适用于中小功率电动车的高性能控制设备，具有出色的能量转换效率和可靠的安全性能。凭借先进的散热设计和高质量元器件，保证长时间稳定运行。',
    specs: [
      { label: '额定电压', value: '72V' },
      { label: '峰值电流', value: '290A' },
      { label: '额定功率', value: '3000W' },
      { label: '效率', value: '≥95%' },
      { label: '工作温度', value: '-20℃~85℃' },
    ],
    features: [
      '先进的FOC矢量控制算法，实现精准转矩控制',
      '内置过压、欠压、过流、过温等多重保护',
      '支持实时数据监控与故障诊断',
      '支持无感和有感运行模式',
      '防水等级达IP65，适应各种恶劣环境'
    ]
  },
  { 
    name: '极核 72350',
    image: CF72350,
    description: '72350型号控制器专为高性能电动摩托车设计，具有更强的瞬时功率输出能力和更先进的控制策略，满足专业骑行的需求。采用强化型MOS管阵列，轻松应对大电流工况。',
    specs: [
      { label: '额定电压', value: '72V' },
      { label: '峰值电流', value: '350A' },
      { label: '额定功率', value: '4000W' },
      { label: '效率', value: '≥96%' },
      { label: '工作温度', value: '-20℃~85℃' },
    ],
    features: [
      '自适应矢量控制技术，动态调整输出参数',
      '多模式驱动选择，满足不同骑行场景需求',
      '升级版散热设计，持续高功率输出无忧',
      '智能电池管理系统接口，精确监测电池状态',
      '支持扭矩传感器输入，实现精确助力控制'
    ]
  },
  { 
    name: '极核 72450',
    image: NB72290,
    description: '72450型号是极核系列中的高端型号，采用最新的控制器技术，为高端电动摩托车和小型电动车提供卓越的驱动性能。镜面铝合金外壳不仅美观，还提供卓越的散热性能。',
    specs: [
      { label: '额定电压', value: '72V' },
      { label: '峰值电流', value: '450A' },
      { label: '额定功率', value: '5000W' },
      { label: '效率', value: '≥97%' },
      { label: '工作温度', value: '-25℃~90℃' },
    ],
    features: [
      '专业级电机控制算法，实现赛车级别加速性能',
      '高精度电流传感和控制，最小化能量损耗',
      '先进的热管理系统，确保极限条件下稳定运行',
      '支持蓝牙和CAN总线通信，便于系统集成和调试',
      '可编程参数设置，满足个性化驾驶需求'
    ]
  },
  { 
    name: '极核 72700',
    image: gn,
    description: '72700型号是极核系列的旗舰产品，为高功率电动车辆提供极致性能，是专业电动赛车和高性能电动摩托车的理想选择。集成航空级电子元件，确保在极限条件下的可靠运行。',
    specs: [
      { label: '额定电压', value: '72V' },
      { label: '峰值电流', value: '700A' },
      { label: '额定功率', value: '8000W' },
      { label: '效率', value: '≥98%' },
      { label: '工作温度', value: '-25℃~95℃' },
    ],
    features: [
      '赛车级别高精度控制系统，毫秒级响应',
      '多核处理器架构，实现复杂控制算法的实时执行',
      '革新性相位预测技术，极大提升高速效率',
      '内置数据记录功能，支持性能分析和故障诊断',
      '军工级元器件，确保极端条件下的可靠性'
    ]
  },
  { 
    name: '九号控制器',
    image: cz,
    description: '九号控制器采用独特的九相控制技术，为电动车提供更平顺的驱动体验和更高的能量利用率，特别适合长途骑行场景。紧凑结构设计使其成为特殊安装空间的理想选择。',
    specs: [
      { label: '额定电压', value: '48V/60V/72V' },
      { label: '峰值电流', value: '400A' },
      { label: '额定功率', value: '3000W-6000W' },
      { label: '效率', value: '≥96%' },
      { label: '工作温度', value: '-20℃~85℃' },
    ],
    features: [
      '创新的九相控制技术，显著减少转矩脉动',
      '自适应电压调节，适应宽范围电池电压',
      '智能功率管理，优化能量使用效率',
      '先进的再生制动系统，延长续航里程',
      '集成式设计，体积小巧，安装便捷'
    ]
  }
];

const activeCategory = ref(0);
const activeItem = computed(() => {
  return categories[activeCategory.value];
});

function setActiveCategory(index) {
  activeCategory.value = index;
}
</script>

<style lang="scss" scoped>
.controller-categories {
  min-height: 100vh;
  background: linear-gradient(135deg, #0f1923 0%, #162432 50%, #1c2f3e 100%);
  color: #e0f7fa;
  font-family: 'Microsoft YaHei', 'Segoe UI', sans-serif;
  padding: 20px;
  box-sizing: border-box;
  overflow: hidden;
  position: relative;

  &::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: 
      radial-gradient(circle at 20% 35%, rgba(0, 170, 255, 0.05) 0%, transparent 25%),
      radial-gradient(circle at 75% 65%, rgba(0, 170, 255, 0.05) 0%, transparent 25%);
    pointer-events: none;
    z-index: 0;
  }
}

.sci-fi-container {
  max-width: 1100px;
  margin: 0 auto;
  background-color: rgba(7, 23, 36, 0.85);
  border-radius: 16px;
  padding: 30px 20px;
  box-shadow: 0 0 30px rgba(0, 170, 255, 0.25),
              0 0 8px rgba(0, 170, 255, 0.1);
  position: relative;
  overflow: hidden;
  z-index: 1;
  
  &::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 4px;
    background: linear-gradient(90deg, 
      rgba(0, 170, 255, 0), 
      rgba(0, 170, 255, 0.8), 
      rgba(0, 170, 255, 0));
  }
}

.sci-fi-header {
  text-align: center;
  padding: 10px 0 30px;
  position: relative;
  margin-bottom: 20px;

  .glow-text {
    font-size: 36px;
    font-weight: 700;
    color: #e0f7fa;
    text-shadow: 0 0 10px rgba(0, 170, 255, 0.5), 
                 0 0 20px rgba(0, 170, 255, 0.3);
    margin: 0;
    letter-spacing: 2px;
    position: relative;
    display: inline-block;
  }

  .sci-fi-decor {
    width: 60%;
    height: 2px;
    background: linear-gradient(90deg, 
      rgba(0, 170, 255, 0), 
      rgba(0, 170, 255, 0.8), 
      rgba(0, 170, 255, 0));
    margin: 15px auto 0;
    position: relative;
    
    &::before, &::after {
      content: '';
      position: absolute;
      width: 10px;
      height: 10px;
      border-radius: 50%;
      background-color: rgba(0, 170, 255, 0.8);
      top: 50%;
      transform: translateY(-50%);
    }
    
    &::before {
      left: 30%;
    }
    
    &::after {
      right: 30%;
    }
  }
}

.category-container {
  display: flex;
  flex-direction: column;
  gap: 30px;
}

.category-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 15px;
  padding: 0 5px;
  
  @media (max-width: 768px) {
    grid-template-columns: repeat(3, 1fr);
  }
  
  @media (max-width: 480px) {
    grid-template-columns: repeat(2, 1fr);
  }
}

.category-item {
  background-color: rgba(12, 28, 43, 0.7);
  border: 1px solid rgba(0, 170, 255, 0.2);
  border-radius: 8px;
  padding: 15px;
  transition: all 0.3s cubic-bezier(0.215, 0.610, 0.355, 1.000);
  cursor: pointer;
  text-align: center;
  position: relative;
  overflow: hidden;
  
  &:hover, &.active {
    border-color: rgba(0, 170, 255, 0.7);
    background-color: rgba(15, 40, 60, 0.9);
    transform: translateY(-5px);
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.3);
    
    .icon-circle {
      transform: scale(1.2);
      background-color: rgba(0, 170, 255, 0.7);
    }
    
    .icon-pulse {
      animation: pulse 2s infinite;
    }
    
    &::before {
      transform: translateX(0);
      opacity: 0.3;
    }
  }
  
  &::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, rgba(0, 170, 255, 0), rgba(0, 170, 255, 0.2), rgba(0, 170, 255, 0));
    transform: translateX(-100%);
    transition: transform 0.6s ease;
    pointer-events: none;
    opacity: 0;
  }
  
  .item-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    z-index: 1;
    
    span {
      margin-top: 10px;
      font-weight: 500;
    }
  }
  
  .tech-icon {
    position: relative;
    width: 40px;
    height: 40px;
    
    .icon-circle {
      width: 30px;
      height: 30px;
      border-radius: 50%;
      background-color: rgba(0, 170, 255, 0.3);
      position: absolute;
      top: 50%;
      left: 50%;
      transform: translate(-50%, -50%);
      transition: all 0.3s;
    }
    
    .icon-pulse {
      width: 40px;
      height: 40px;
      border-radius: 50%;
      border: 1px solid rgba(0, 170, 255, 0.4);
      position: absolute;
      top: 50%;
      left: 50%;
      transform: translate(-50%, -50%);
    }
  }
}

@keyframes pulse {
  0% {
    transform: translate(-50%, -50%) scale(0.8);
    opacity: 0.8;
  }
  70% {
    transform: translate(-50%, -50%) scale(1.2);
    opacity: 0;
  }
  100% {
    transform: translate(-50%, -50%) scale(0.8);
    opacity: 0;
  }
}

.category-content {
  padding: 10px 5px;
}

.tech-frame {
  background-color: rgba(12, 28, 43, 0.7);
  border: 1px solid rgba(0, 170, 255, 0.3);
  border-radius: 12px;
  padding: 25px;
  position: relative;
  overflow: hidden;
  box-shadow: 0 5px 20px rgba(0, 0, 0, 0.2);
  animation: fadeIn 0.5s ease-out;
  
  &::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: 
      linear-gradient(135deg, rgba(0, 170, 255, 0.05) 0%, transparent 100%),
      repeating-linear-gradient(45deg, transparent, transparent 10px, rgba(0, 170, 255, 0.03) 10px, rgba(0, 170, 255, 0.03) 11px);
    pointer-events: none;
    z-index: 0;
  }
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.frame-corner {
  position: absolute;
  width: 20px;
  height: 20px;
  border-color: rgba(0, 170, 255, 0.6);
  border-style: solid;
  border-width: 0;
  z-index: 1;
  
  &.top-left {
    top: 0;
    left: 0;
    border-top-width: 2px;
    border-left-width: 2px;
    border-top-left-radius: 8px;
  }
  
  &.top-right {
    top: 0;
    right: 0;
    border-top-width: 2px;
    border-right-width: 2px;
    border-top-right-radius: 8px;
  }
  
  &.bottom-left {
    bottom: 0;
    left: 0;
    border-bottom-width: 2px;
    border-left-width: 2px;
    border-bottom-left-radius: 8px;
  }
  
  &.bottom-right {
    bottom: 0;
    right: 0;
    border-bottom-width: 2px;
    border-right-width: 2px;
    border-bottom-right-radius: 8px;
  }
}

.content-header {
  margin-bottom: 25px;
  position: relative;
  z-index: 1;
  
  h2 {
    font-size: 28px;
    color: #00aaff;
    margin: 0 0 12px;
    text-shadow: 0 0 10px rgba(0, 170, 255, 0.3);
    font-weight: 600;
    letter-spacing: 1px;
  }
  
  .tech-line {
    height: 2px;
    background: linear-gradient(90deg,
      rgba(0, 170, 255, 0.1),
      rgba(0, 170, 255, 0.5),
      rgba(0, 170, 255, 0.1));
  }
}

.content-body {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  gap: 25px;
}

.tech-specs {
  display: flex;
  gap: 30px;
  flex-wrap: wrap;
  
  @media (max-width: 768px) {
    flex-direction: column;
  }
}

.tech-image {
  flex: 0 0 45%;
  border: 2px solid rgba(0, 170, 255, 0.2);
  border-radius: 10px;
  overflow: hidden;
  position: relative;
  box-shadow: 0 10px 20px rgba(0, 0, 0, 0.3);
  max-height: 300px;
  
  @media (max-width: 768px) {
    flex: 0 0 100%;
  }
  
  img {
    width: 100%;
    height: 100%;
    display: block;
    transition: transform 0.8s ease;
  }
  
  &:hover {
    img {
      transform: scale(1.05);
    }
    
    .scanning-line {
      opacity: 1;
    }
  }
  
  .image-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, rgba(0, 170, 255, 0.1) 0%, transparent 100%);
    pointer-events: none;
  }
  
  .scanning-line {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 4px;
    background: linear-gradient(90deg, 
      rgba(0, 170, 255, 0), 
      rgba(0, 170, 255, 0.8), 
      rgba(0, 170, 255, 0));
    animation: scanning 3s linear infinite;
    opacity: 0.5;
    transition: opacity 0.3s;
  }
}

@keyframes scanning {
  0% {
    transform: translateY(0);
  }
  100% {
    transform: translateY(300px);
  }
}

.specs-list {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 15px;
}

.spec-item {
  background-color: rgba(0, 0, 0, 0.2);
  border: 1px solid rgba(0, 170, 255, 0.2);
  border-radius: 8px;
  padding: 10px 15px;
  transition: all 0.3s;
  overflow: hidden;
  position: relative;
  
  &:hover {
    border-color: rgba(0, 170, 255, 0.4);
    background-color: rgba(0, 170, 255, 0.05);
    transform: translateY(-3px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
  }
  
  .spec-label {
    font-size: 14px;
    color: rgba(224, 247, 250, 0.7);
    margin-bottom: 5px;
  }
  
  .spec-value {
    font-size: 20px;
    color: #00aaff;
    font-weight: 600;
  }
}

.tech-description, .tech-features {
  margin-top: 10px;
  
  h3 {
    font-size: 20px;
    font-weight: 600;
    color: #e0f7fa;
    margin: 0 0 15px;
    padding-left: 15px;
    border-left: 3px solid rgba(0, 170, 255, 0.7);
  }
  
  p {
    line-height: 1.6;
    color: rgba(224, 247, 250, 0.85);
    margin: 0;
    font-size: 16px;
  }
}

.tech-features ul {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 15px;
}

.tech-features li {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 5px;
  transition: transform 0.3s;
  
  &:hover {
    transform: translateX(5px);
    
    .feature-bullet {
      background-color: rgba(0, 170, 255, 0.9);
    }
  }
  
  .feature-bullet {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background-color: rgba(0, 170, 255, 0.5);
    margin-top: 6px;
    flex-shrink: 0;
    transition: background-color 0.3s;
  }
}

.kzq-carousel {
  margin-bottom: 30px;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid rgba(0, 170, 255, 0.3);
  box-shadow: 0 0 20px rgba(0, 0, 0, 0.3);
  
  :deep(.carousel__slide) {
    padding: 0;
  }
  
  :deep(.carousel__viewport) {
    border-radius: 12px;
  }

  :deep(.carousel__pagination) {
    padding: 10px 0;
    
    .carousel__pagination-button {
      &::after {
        width: 10px;
        height: 10px;
        border-radius: 50%;
        background-color: rgba(0, 170, 255, 0.3);
        transition: all 0.3s;
      }
      
      &--active::after {
        background-color: rgba(0, 170, 255, 0.9);
        transform: scale(1.2);
      }
    }
  }
  
  :deep(.carousel__prev),
  :deep(.carousel__next) {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background-color: rgba(0, 0, 0, 0.5);
    color: white;
    border: 1px solid rgba(0, 170, 255, 0.5);
    transition: all 0.3s;
    
    &:hover {
      background-color: rgba(0, 170, 255, 0.8);
      transform: scale(1.1);
    }
  }
}

.carousel-slide {
  aspect-ratio: 16 / 9;
  overflow: hidden;
  
  .carousel-image {
    width: 100%;
    height: 100%;
    transition: transform 0.8s ease;
    
    &:hover {
      transform: scale(1.03);
    }
  }
}

@media (max-width: 768px) {
  .sci-fi-container {
    padding: 20px 15px;
  }
  
  .tech-frame {
    padding: 20px 15px;
  }
  
  .content-header h2 {
    font-size: 24px;
  }
  
  .tech-features ul {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 480px) {
  .sci-fi-header .glow-text {
    font-size: 28px;
  }
  
  .specs-list {
    grid-template-columns: 1fr;
  }
}
</style> 